Add some bounds checking to values passed when changing the period and
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 8 Mar 2006 10:48:34 +0000 (11:48 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 8 Mar 2006 10:48:34 +0000 (11:48 +0100)
slice of a domain using the sedf scheduler.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
xen/common/sched_sedf.c

index 38594e04614993ce149bfdce7d86199434a3cc57..994ecdfd8ef76cc7128f63096e83cb7cd6a630b2 100644 (file)
 #define WEIGHT_PERIOD (MILLISECS(100))
 #define WEIGHT_SAFETY (MILLISECS(5))
 
+/* FIXME: need to validate that these are sane */
+#define PERIOD_MAX ULONG_MAX
+#define PERIOD_MIN (MICROSECS(10))
+#define SLICE_MAX ULONG_MAX
+#define SLICE_MIN (MICROSECS(5))
+
 #define IMPLY(a, b) (!(a) || (b))
 #define EQ(a, b) ((!!(a)) == (!!(b)))
 
@@ -1609,7 +1615,10 @@ static int sedf_adjdom(struct domain *p, struct sched_adjdom_cmd *cmd)
                  * Sanity checking: note that disabling extra weight requires
                  * that we set a non-zero slice.
                  */
-                if ( (cmd->u.sedf.slice == 0) ||
+                if ( (cmd->u.sedf.period > PERIOD_MAX) ||
+                     (cmd->u.sedf.period < PERIOD_MIN) ||
+                     (cmd->u.sedf.slice  > SLICE_MAX)  ||
+                     (cmd->u.sedf.slice  < SLICE_MIN)  ||
                      (cmd->u.sedf.slice > cmd->u.sedf.period) )
                     return -EINVAL;
                 EDOM_INFO(v)->weight = 0;